/**
 * 角色和权限配置
 */

// 角色定义
const ROLES = {
    ADMIN: 'admin',           // 系统管理员
    MANAGER: 'manager',       // 部门管理员
    STAFF: 'staff',          // 普通员工
    USER: 'user'             // 普通用户
};

// 权限定义
const PERMISSIONS = {
    // 工单相关权限
    WORKORDER: {
        CREATE: 'workorder:create',
        VIEW: 'workorder:view',
        EDIT: 'workorder:edit',
        DELETE: 'workorder:delete',
        ASSIGN: 'workorder:assign'
    },
    // 设备相关权限
    EQUIPMENT: {
        CREATE: 'equipment:create',
        VIEW: 'equipment:view',
        EDIT: 'equipment:edit',
        DELETE: 'equipment:delete'
    },
    // 用户管理权限
    USER: {
        CREATE: 'user:create',
        VIEW: 'user:view',
        EDIT: 'user:edit',
        DELETE: 'user:delete'
    },
    // 系统设置权限
    SYSTEM: {
        SETTINGS: 'system:settings',
        LOG_VIEW: 'system:log_view'
    }
};

// 角色权限映射
const ROLE_PERMISSIONS = {
    [ROLES.ADMIN]: [
        // 管理员拥有所有权限
        ...Object.values(PERMISSIONS.WORKORDER),
        ...Object.values(PERMISSIONS.EQUIPMENT),
        ...Object.values(PERMISSIONS.USER),
        ...Object.values(PERMISSIONS.SYSTEM)
    ],
    [ROLES.MANAGER]: [
        // 部门管理员权限
        PERMISSIONS.WORKORDER.CREATE,
        PERMISSIONS.WORKORDER.VIEW,
        PERMISSIONS.WORKORDER.EDIT,
        PERMISSIONS.WORKORDER.ASSIGN,
        PERMISSIONS.EQUIPMENT.VIEW,
        PERMISSIONS.EQUIPMENT.EDIT,
        PERMISSIONS.USER.VIEW
    ],
    [ROLES.STAFF]: [
        // 普通员工权限
        PERMISSIONS.WORKORDER.CREATE,
        PERMISSIONS.WORKORDER.VIEW,
        PERMISSIONS.EQUIPMENT.VIEW
    ],
    [ROLES.USER]: [
        // 普通用户权限
        PERMISSIONS.WORKORDER.CREATE,
        PERMISSIONS.WORKORDER.VIEW
    ]
}; 